/*
 * ipassbook 0.6.0
 * Copyright (C)2009 wateray and contributors
 * wateray@gmail.com
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 */

package com.wateray.ipassbook.ui.dialog.wizard;

import java.awt.Dimension;
import java.awt.Insets;

import javax.swing.JLabel;
import javax.swing.JTextArea;

import com.wateray.ipassbook.domain.Entity;
import com.wateray.ipassbook.domain.form.PassbookForm;
import com.wateray.ipassbook.util.LanguageLoader;

/**
 * @author wateray
 * @create 2009-5-17
 */
public class PassbookWizardPageThree extends AbstractWizardPage {

	/**
	 * serialVersionUID
	 */
	private static final long serialVersionUID = 1L;
	
	private JTextArea confirmArea;
	private JLabel describeLabel;
	
	public PassbookWizardPageThree(IWizardDialog wizardDialog){
		super(wizardDialog);
		initPage();
		
		initData();
	}
	
	protected void initPage(){
       super.initPage();
       
		//getConfirmArea
		constraints.insets =  new Insets(top, left, bottom, right);
		constraints.weightx=1.0;
		constraints.gridy = ++gridy;
		this.add(getConfirmArea(), constraints);
		constraints.weightx = 0.0;
       
		constraints.gridy = ++gridy;
		this.add(getDescribeLabel(), constraints);
		
		//spaceLabelTop
		constraints.weighty=1.0;
		constraints.gridy = ++gridy;
		this.add(new JLabel(), constraints);
		constraints.weighty = 0.0;
       
	}
	
	private JTextArea getConfirmArea(){
		if(confirmArea == null){
			confirmArea = new JTextArea("xyz");
//			confirmArea.setEditable(false);
			confirmArea.setRows(250);
			confirmArea.setPreferredSize(new Dimension(800, 400));
		}
		return confirmArea;
	}

	private JLabel getDescribeLabel(){
		if(describeLabel == null){
			describeLabel = new JLabel(LanguageLoader.getString("PassbookWizardPageThreeDescribe"));
		}
		return describeLabel;
	}
	
	private void initData(){
		
	}
	
	/* (non-Javadoc)
	 * @see com.wateray.ipassbook.ui.dialog.wizard.IWizardPage#checkData()
	 */
	@Override
	public String checkData() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public void processData(Entity entity) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void beforeShowing() {
		// TODO Auto-generated method stub
		PassbookForm passbookEntity = (PassbookForm) this.getWizardDialog().getEntity();
		StringBuffer sb = new StringBuffer();
		sb.append(LanguageLoader.getString("Passbook_Name") + ":" + passbookEntity.getPassbookName() + "\n");
		sb.append(LanguageLoader.getString("Init_Data") + ":" + passbookEntity.getCreateDate() + "\n");
		sb.append(LanguageLoader.getString("Init_Amount") + ":" +  passbookEntity.getCapital() + "\n");
		sb.append(LanguageLoader.getString("Currency") + ":" + passbookEntity.getCurrencyName() + "\n");
		sb.append("\n\n");
		sb.append(LanguageLoader.getString("Describe")  + ":" + passbookEntity.getMemo() + "\n");

		getConfirmArea().setText(sb.toString());
	}
}
